/*
 * @Description: array
 * @Author: rendc
 * @Date: 2022-09-29 09:32:55
 * @LastEditors: rendc
 * @LastEditTime: 2022-09-29 11:02:37
 */
var arr = [1, 2, 3, 4, 5];
var result = arr.every(
  function (item, i, arr) {
    return item > 2; //1 false
  }
);
console.log('🤡 CC - result', result);

var arr = [1, 2, 3, 4, 5];
var result = arr.some(
  function (item, i, arr) {
    return item > 2; //3 true
  }
);
console.log('🤡 CC - result', result);

var arr = [1, 2, 3, 4, 5];
var result = arr.filter(
  function (item, i, arr) {
    return item > 2;
  }
);
console.log('🤡 CC - result', result);

var arr = [1, 2, 3, 4, 5];
var result = arr.map(
  function (item, i, arr) {
    return item * 2 + 3;
  }
);
console.log('🤡 CC - result', result);

var arr = [1, 2, 3, 4, 5];
let newArr = [];
var result = arr.forEach(
  function (item, i, arr) {
    console.log('🤡 CC - item', item);
    let a = item * 2 + 3;
    newArr.push(a);
  }
);
console.log(newArr);

var arr = [1, 2, 3, 4, 5];
arr.forEach(
  item => {
    console.log('🤡 CC - item', item);
  }
  // function (item) {
  //   console.log('🤡 CC - item', item);
  // }
);


// var arrCopy = arr;
// console.log('🤡 CC - arrCopy', arrCopy);
// console.log('🤡 CC - arr', arr);
// arrCopy[0] = 999;
// console.log('🤡 CC - arrCopy', arrCopy);
// console.log('🤡 CC - arr', arr);

var arrCopy = arr.slice();
console.log('🤡 CC - arrCopy', arrCopy);
console.log('🤡 CC - arr', arr);
arrCopy[0] = 999;
console.log('🤡 CC - arrCopy', arrCopy);
console.log('🤡 CC - arr', arr);

var arrCopy = new Array(...arr)
console.log('🤡 CC - arrCopy', arrCopy);

// let [, , , [e, f]] = [1, 2, 3, [4, 5], 6];
let [a, b, c, [e, f]] = [1, 2, 3, [4, 5], 6];
console.log('🤡 CC - e, f', e, f);
console.log('🤡 CC - a, b, c', a, b, c);

// const array1 = [5, 12, 50, 130, 44];
// node环境暂不支持
// const found = array1.findLast((element) => element > 45);

// console.log(found);